executeQuery

用途

执行任意的 HQL queries

举例

// simple query
Account.executeQuery( "select distinct a.number from Account a" );
// using with list of parameters
Account.executeQuery( "select distinct a.number from Account a where a.branch = ? and a.created > ?", ['London',lastMonth] );
// using with a single parameter and pagination params (since 0.5)
Account.executeQuery( "select distinct a.number from Account a where a.branch = ?", ['London'], [max:10,offset:5] );
// using with Map of named parameters (since 0.5)
Account.executeQuery( "select distinct a.number from Account a where a.branch = :branch", [branch:'London'] );
// using with Map of named parameters and pagination params (since 0.5)
Account.executeQuery( "select distinct a.number from Account a where a.branch = :branch", [branch:'London', max:10, offset:5] );
// same as previous
Account.executeQuery( "select distinct a.number from Account a where a.branch = :branch", [branch:'London'], [max:10, offset:5] );

描述

executeQuery 方法可以执行任意的 HQL queries,不一定要返回domain类的实例,这在仅仅需要对象的部分数据时非常有用。基本的语法如下:

Book.executeQuery( String query )
Book.executeQuery( String query, Collection positionalParams )
Book.executeQuery( String query, Collection positionalParams, Map paginateParams )
Book.executeQuery( String query, Map namedParams )
Book.executeQuery( String query, Map namedParams, Map paginateParams )

参数: